#ifndef __ATLAS_STRUCT_EDITOR_VIEW__
#define __ATLAS_STRUCT_EDITOR_VIEW__


#include <wx/propgrid/propgrid.h>
#include <wx/propgrid/advprops.h>
#include "PropertyEx.h"
#include <CommonDDL.h>

class wxBoxSizer;
class CContentDataView;

class CStructEditView : public wxPanel
{
	DECLARE_EVENT_TABLE()

public:
	CStructEditView(wxWindow* pParent, wxWindow* pDataViewWindow);
	virtual ~CStructEditView();
		
	void Clear();
	bool IsModify();
	void SetDebugModel();
	void InitPropGrid(const DDLReflect::STRUCT_INFO* info, const void* data, bool bTopLevel = true, wxPGId parent_pgid = 0);
	bool Set(const DDLReflect::STRUCT_INFO* info, const void* data);
	bool Get(const DDLReflect::STRUCT_INFO* info, void* data);	
	void* Undo();
	void FlashView();
	bool UpdateGrid();
	bool IsDiffItem();
	void ValidateNullValue(wxArrayString& strArrayString);

    void OnPropertyGridChange(wxPropertyGridEvent& event); 
    void OnPropertyGridChanging(wxPropertyGridEvent& event); 

private:
	wxPGProperty* CreatePropertyByType(wxString strValueName, _U8 type, const void* data, const _U32 flags = 0x00, const char* ref_type = NULL, const char* struct_type=NULL);
	void SetText(const DDLReflect::STRUCT_INFO* info, const void* data);
	bool ValidataPropIsNull(wxPGProperty* prop, wxVariant& pendingValue = wxNullVariant);

private:
	wxTextCtrl* m_pText;
	wxPropertyGrid* m_pPropGrid;
	wxPGId m_parentID;
	wxBoxSizer* m_pSizer;

	void* m_data;			//a copy for source to cancel operation
	void* m_pDataAddr;		//point to source data
	const DDLReflect::STRUCT_INFO* m_pInfo;	//point to source struct_info
	bool m_bModify;
	A_UUID m_uuidLastModify;	//the item modified last time

	CContentDataView* m_pDataViewWindow;
};

#endif
